﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>云科技</title>
    <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css"/>
    <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css"/>
    <script src="../js/jquery-2.2.4.min.js"></script>

    <!--<link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.css" rel="stylesheet">-->
    <!--<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.js"></script>-->
    <script language="javascript" type="text/javascript">
        //删除
        function deleteAccount() {
            var r = window.confirm("确定要删除此账务账号吗？\r\n删除后将不能恢复，且会删除其下属的所有业务账号。");
            document.getElementById("operate_result_info").style.display = "block";

        }

        //开通或暂停
        function setState() {
            var r = window.confirm("确定要开通此账务账号吗？");
            document.getElementById("operate_result_info").style.display = "block";
        }

        function setState1() {
            var r = window.confirm("确定要暂停此账务账号吗？");
            document.getElementById("operate_result_info").style.display = "block";
        }
    </script>
    <script src="../js/boot-account.js"></script>
    <script src="../js/custom-account.js"></script>
    <script src="../js/module.js"></script>
</head>
<body>
<!--Logo区域开始-->
<div id="header">
    <img src="../images/logo.png" alt="logo" class="left"/>
    <a href="#">[退出]</a>
</div>
<!--Logo区域结束-->
<!--导航区域开始-->
<div id="navi">
    <ul id="menu">
        <li><a href="../index.html" class="index_off"></a></li>
        <li><a href="../user/user_info.html" class="information_off"></a></li>
        <li><a href="../user/user_modi_pwd.html" class="password_off"></a></li>
    </ul>
</div>
<!--导航区域结束-->
<!--主要区域开始-->
<div id="main">
    <form action="" method="post">
        <!--查询-->

        <div id="search" class="search_add">
            <div>身份证：<input id="idCardSearch" type="text" class="text_search"/></div>
            <div>姓名：<input id="realNameSearch" type="text" class="width70 text_search"/></div>
            <div>登录名：<input id="loginNameSearch" type="text" class="text_search"/></div>
            <div>
                状态：
                <select id="status" class="select_search">
                    <option>全部</option>
                    <option>开通</option>
                    <option>暂停</option>
                    <option>删除</option>
                </select>
            </div>
            <div><input id="searchBtn" type="button" value="搜索" class="btn_search"/></div>


            <input type="button" value="增加" class="btn_add" onclick="location.href='account_add.html';"/>


        </div>
        <!--删除等的操作提示-->
        <div id="operate_result_info" class="operate_success">
            <img src="../images/close.png" onclick="this.parentNode.style.display='none';"/>
            删除成功，且已删除其下属的业务账号！
        </div>
        <!--数据区域：用表格展示数据-->
        <div id="data">
            <table id="datalist">
                <tr>
                    <th>账号ID</th>
                    <th>姓名</th>
                    <th class="width150">身份证</th>
                    <th>登录名</th>
                    <th>状态</th>
                    <th class="width100">创建日期</th>
                    <th class="width150">上次登录时间</th>
                    <th class="width200"></th>
                </tr>
                <tbody id="tbody"></tbody>

                <script type="text/javascript">
                    var id;
                    $(function () {

                        //查看
                        $.ajax({
                            type: "GET",
                            url: "/kobe/account/findAll",
                            dataType: "json",
                            // async: false,
                            success: function (data) {
                                // console.log(data);
                                var tbody = $('#tbody');
                                // tbody.empty();
                                for (var item of data) {
                                    var tr = $('<tr></tr>');
                                    var accountId = $('<td></td>').text(item.accountId);
                                    var realName = $('<td></td>').text(item.realName);
                                    var idCard = $('<td></td>').text(item.idcardNo);
                                    // var moduleInfos = item.roleModule.moduleInfoList;
                                    var loginName = $('<td></td>').text(item.loginName);
                                    var status = $('<td></td>').text(item.status);
                                    var createDate = $('<td></td>').text(item.createDate);
                                    var lastLoginTime = $('<td></td>').text(item.lastLoginTime);
                                    var td = $('<td></td>');
                                    if (item.status === "0") {
                                        var stput = $('<input type="button" value="暂停" class="btn_pause" onclick="setState();" />');
                                    }
                                    if (item.status === "1") {
                                        var startput = $('<input type="button" value="开通" class="btn_start" onclick="setState1();" />');
                                    }
                                    var modput = $('<input type="button" value="修改" class="btn_modify" />');
                                    var delput = $('<input type="button" value="删除" class="btn_delete" onclick="deleteAccount();"/>');
                                    if (item.status === "0") {
                                        td.append(stput)
                                    }
                                    if (item.status === "1") {
                                        td.append(startput)
                                    }
                                    td.append(modput).append(delput);
                                    tr.append(accountId).append(realName).append(idCard).append(loginName).append(status).append(createDate).append(lastLoginTime).append(td);
                                    tbody.append(tr);
                                }
                            }
                        })


                    })
                    ;

                    //表单的按钮添加事件
                    $('#datalist').click(function (e) {
                        //获取目标里的第一个内容(parentNode父级\firstChild第一个儿子\textContent获取内容)
                        id = e.target.parentNode.parentNode.firstChild.textContent;
                        console.log(e.target.value);
                        console.log(id);
                        //获取点击的内容
                        var elem = e.target.value;

                        if (elem === "暂停" || elem === "开通") {
                            $.ajax({
                                url: "/kobe/account/upStatus",
                                type: "POST",
                                data: {
                                    "accountId": id
                                },
                                //刷新页面
                                success: function (resp) {
                                    location.reload(true)
                                }
                            })
                        }
                        if (elem === "删除") {
                            $.ajax({
                                url: "/kobe/account/deleteById",
                                type: "POST",
                                data: {
                                    "accountId": id
                                },
                                //刷新页面
                                success: function (resp) {
                                    location.reload(true)
                                }
                            })
                        }
                        if (elem === "修改") {
                            location.href = "account_modi.html?accountId=" + id;
                        }

                    });
                    $('#searchBtn').click(function () {
                        var idCardSearch = $("#idCardSearch").val();
                        var realNameSearch = $("#realNameSearch").val();
                        var loginNameSearch = $("#loginNameSearch").val();
                        var status = $("#status").val();
                        var url = "/kobe/account/search";
                        var data = {
                            "idcardNo": idCardSearch,
                            "realName": realNameSearch,
                            "loginName": loginNameSearch,
                            "status": status

                        };
                        // console.log(status);
                        $.get(url, data, function (resp) {
                            console.log(realNameSearch);
                            console.log(resp)

                            console.log('111')
                            var tbody = $('#tbody');
                            tbody.empty();
                            for (var item of resp) {
                                var tr = $('<tr></tr>');
                                var accountId = $('<td></td>').text(item.accountId);
                                var realName = $('<td></td>').text(item.realName);
                                var idCard = $('<td></td>').text(item.idcardNo);
                                var loginName = $('<td></td>').text(item.loginName);
                                var status = $('<td></td>').text(item.status);
                                var createDate = $('<td></td>').text(item.createDate);
                                var lastLoginTime = $('<td></td>').text(item.lastLoginTime);
                                var td = $('<td></td>');
                                if (item.status === "0") {
                                    var stput = $('<input type="button" value="暂停" class="btn_pause" onclick="setState();" />');
                                }
                                if (item.status === "1") {
                                    var startput = $('<input type="button" value="开通" class="btn_start" onclick="setState1();" />');
                                }
                                var modput = $('<input type="button" value="修改" class="btn_modify" />');
                                var delput = $('<input type="button" value="删除" class="btn_delete" onclick="deleteAccount();"/>');
                                if (item.status === "0") {
                                    td.append(stput)
                                }
                                if (item.status === "1") {
                                    td.append(startput)
                                }
                                td.append(modput).append(delput);
                                tr.append(accountId).append(realName).append(idCard).append(loginName).append(status).append(createDate).append(lastLoginTime).append(td);
                                tbody.append(tr);
                            }
                        });
                        // console.log(resp);
                    })


                </script>

            </table>

        </div>
        <!--分页-->
        <div id="pages">
            <button id="firstPage">首页</button>
            <button id="prev">上一页</button>
            <ul id="ul" style="display: inline-block">
            </ul>
            <button id="next">下一页</button>
            <button id="endPage">末页</button>
        </div>
    </form>
    <p>业务说明：<br/>
        1、创建则开通，记载创建时间；<br/>
        2、暂停后，记载暂停时间；<br/>
        3、重新开通后，删除暂停时间；<br/>
        4、删除后，记载删除时间，标示为删除，不能再开通、修改、删除；<br/>
        5、暂停账务账号，同时暂停下属的所有业务账号；<br/>
        6、暂停后重新开通账务账号，并不同时开启下属的所有业务账号，需要在业务账号管理中单独开启；<br/>
        7、删除账务账号，同时删除下属的所有业务账号。</p>


</div>
<!--主要区域结束-->
<div id="footer">
    <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
    <p>版权所有(C)云科技有限公司 </p>
</div>
</body>



</html>
